//
//  FTSearchViewController.m
//  项目2
//
//  Created by rimi on 16/8/19.
//  Copyright © 2016年 wzc. All rights reserved.
//

#import "FTSearchViewController.h"
#import "FTSearchBar.h"
#import "FTConfigDefine.h"

@interface FTSearchViewController ()<UISearchBarDelegate>
@property (strong, nonatomic) UISearchBar *searchBar;
@property (strong, nonatomic) UIBarButtonItem *searchBtn;
@end

@implementation FTSearchViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];

    self.navigationItem.titleView = self.searchBar;

    self.navigationItem.rightBarButtonItem = self.searchBtn;
}
-(UIBarButtonItem *)searchBtn{
    if (!_searchBtn) {
//        UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 40, 20)];
//        btn.tintColor = [UIColor whiteColor];
//        [btn setTitle:@"搜索" forState:UIControlStateNormal];
//        [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _searchBtn = [[UIBarButtonItem alloc]initWithTitle:@"搜索" style:UIBarButtonItemStylePlain target:self action:@selector(getSearch)];
//        _searchBtn = [[UIBarButtonItem alloc]initWithCustomView:btn];
        
//        [btn setBackgroundColor:[UIColor blueColor]];
//        _searchBtn.title = @"搜索";
//
    }
    return _searchBtn;
}
-(void)getSearch{
    PLLOG(@"123");
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(UISearchBar *)searchBar{
    if (!_searchBar) {
        _searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth-100, 30)];
        _searchBar.delegate = self;
        _searchBar.placeholder = @"请输入关键字";
//        _searchBar.layer.borderColor = [UIColor whiteColor].CGColor;
//        _searchBar.backgroundColor = [UIColor whiteColor];
        _searchBar.layer.cornerRadius = 5;
    }
    return _searchBar;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
